//
//  M4InfosTipImageView.swift
//  M4
//
//  Created by YuChuang on 2024/8/10.
//

import UIKit

class M4InfosTipImageView: UIView {
    
    lazy var tipImageVIew: UIImageView = {
        let img = UIImageView()
        img.contentMode = .scaleAspectFit
        return img
    }()

    override init(frame: CGRect) {
        super.init(frame: .zero)
        self.addSubview(tipImageVIew)
        tipImageVIew.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
            make.top.bottom.equalToSuperview()
//            make.height.equalTo(44)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

class M4InfosBottomView: UIView {
    
    var m4BottomButtonBlock: ((UIButton) -> Void)?
    
    lazy var m4submitButton: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitle("Enviar", for: .normal)
        button.setTitleColor(.white, for: .normal)
        button.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: .regular)
        button.backgroundColor = COLOR_00479D
        button.layer.cornerRadius = 2
        button.addTarget(self, action: #selector(m4submitClick), for: .touchUpInside)
        return button
    }()
    
    lazy var m4safeImage: UIImageView = {
        let img = UIImageView()
        img.image = UIImage(named: "icon_safe")
        return img
    }()
    
    lazy var m4tipLabel: UILabel = {
        let label = UILabel()
        label.text = "Protección de la intimidad"
        label.textColor = COLOR_999999
        label.font = UIFont.systemFont(ofSize: 12, weight: .regular)
        return label
    }()
    
    lazy var m4View: M4DecriptionStringView = {
        let V = M4DecriptionStringView(M4IsCheck: true, c: nil, M4BtnSelectedStatus: nil)
        return V
    }()
    
    override init(frame: CGRect) {
        super.init(frame: .zero)
        self.addSubview(m4submitButton)
        m4submitButton.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.height.equalTo(44)
            make.left.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
        }
        self.addSubview(m4safeImage)
        m4safeImage.snp.makeConstraints { make in
            make.top.equalTo(m4submitButton.snp.bottom).offset(10)
            make.width.equalTo(10)
            make.height.equalTo(12)
//            make.bottom.equalToSuperview()
        }
        self.addSubview(m4tipLabel)
        m4tipLabel.snp.makeConstraints { make in
            make.centerX.equalToSuperview().offset(8)
            make.left.equalTo(m4safeImage.snp.right).offset(6)
            make.centerY.equalTo(m4safeImage)
        }
        
        self.addSubview(m4View)
        m4View.snp.makeConstraints { make in
            make.left.right.equalTo(m4submitButton)
            make.top.equalTo(m4tipLabel.snp.bottom).offset(4)
            make.bottom.equalToSuperview()
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc private func m4submitClick() {
        m4BottomButtonBlock?(m4submitButton)
    }
    
}
